package com.choosefine.base.shixiaobao.base;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;

import com.choosefine.base.shixiaobao.common.model.CustomRestTemplate;


public class RefitRestTemplate {
	
	@Autowired
	public CustomRestTemplate restTemplate;
	
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url POST请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByPOST(String url,Object... urlVariables){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.POST,null, String.class,urlVariables);
		String result = responseEntity.getBody();
		return result;
	}
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url POST请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByPOST(String url,Map<String, ?> urlVariables){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.POST,null, String.class,urlVariables);
		String result = responseEntity.getBody();
		return result;
	}
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url PUT请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByPUT(String url,Object... urlVariables){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.PUT,null, String.class,urlVariables);
		String result = responseEntity.getBody();
		return result;
	}
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url PUT请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByPUT(String url,Map<String, ?> urlVariables){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.PUT,null, String.class,urlVariables);
		String result = responseEntity.getBody();
		return result;
	}
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url GET请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByGET(String url,Object... urlVariables){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.GET,null, String.class,urlVariables);
		String result = responseEntity.getBody();
		return result;
	}
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url GET请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByGET(String url,Map<String, ?> urlVariables){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.GET,null, String.class,urlVariables);
		String result = responseEntity.getBody();
		return result;
	}
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url DELETE请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByDELETE(String url,Object... urlVariables){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.DELETE,null, String.class,urlVariables);
		String result = responseEntity.getBody();
		return result;
	}
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url DELETE请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByDELETE(String url,Map<String, ?> urlVariables){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.DELETE,null, String.class,urlVariables);
		String result = responseEntity.getBody();
		return result;
	}
	
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url PUTRestfulStyle请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByPUTRestfulStyle(String url){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.PUT, null, String.class);
		String result = responseEntity.getBody();
		return result;
	}
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url GETRestfulStyle请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByGETRestfulStyle(String url){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.GET, null, String.class);
		String result = responseEntity.getBody();
		return result;
	}
	/**
	 * @author chenjian
	 * @time 2016-12-17 下午4:50:11
	 * @param url DELETERestfulStyle请求链接
	 * @param urlVariables 请求数据对象
	 */
	public String requestByDELETERestfulStyle(String url){
		ResponseEntity<String> responseEntity = restTemplate.exchange(url,HttpMethod.DELETE, null, String.class);
		String result = responseEntity.getBody();
		return result;
	}
	
	
}
